﻿using GN.Pay.Core.Values.Services;
using GN.Pay.TradeChannel;
using GN.Pay.TradeChannel.DefaultImpl;
using GN.Pay.TradeChannel.ProtocolPay;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Values.Channel
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class MerchantMemberBankCardBindApplyInfo
    {
        /// <summary>
        /// 应用Id
        /// </summary>
        [Required]
        [MaxLength(32)]
        public string AppId { get; set; }

        /// <summary>
        /// 支付内部会员Id
        /// </summary>
        [Required]
        [MaxLength(32)]
        public string MemberId { get; set; }

        /// <summary>
        /// 银行编号
        /// </summary>
        [Required]
        [MaxLength(20)]
        public string BankNo { get; set; }

        /// <summary>
        /// 卡号或账号
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string AccountNo { get; set; }

        /// <summary>
        /// 户名
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string AccountName { get; set; }

        /// <summary>
        /// 身份证号
        /// </summary>
        [Required]
        [MaxLength(30)]
        public string IdentityNo { get; set; }

        /// <summary>
        /// 账户类型(借记或贷记,常量组 = 1)
        /// </summary>
        public int AccountType { get; set; }

        /// <summary>
        /// 开户行名称
        /// </summary>
        [MaxLength(50)]
        public string OpenBankName { get; set; }

        /// <summary>
        /// 开户行省份
        /// </summary>
        [MaxLength(50)]
        public string OpenBankProvince { get; set; }

        /// <summary>
        /// 开户行所在城市
        /// </summary>
        [MaxLength(20)]
        public string OpenBankCity { get; set; }

        /// <summary>
        /// 预留手机号
        /// </summary>
        [Required]
        [MaxLength(20)]
        public string MobilePhone { get; set; }

        /// <summary>
        /// 信用卡有效期
        /// </summary>
        [MaxLength(20)]
        public string CreditCardLastTerm { get; set; }

        /// <summary>
        /// 信用卡尾号
        /// </summary>
        [MaxLength(20)]
        public string CreditCardLastNo { get; set; }

        /// <summary>
        /// 创建
        /// </summary>
        /// <returns></returns>
        public IProtocolBindApply CreateShortcutBindApply()
        {
            return new ProtocolBindApply()
            {
                AccountName = AccountName,
                AccountNo = AccountNo,
                AccountType = (BankAccountType)AccountType,
                BankNo = BankNo,
                CreditCardLastNo = CreditCardLastNo,
                CreditCardLastTerm = CreditCardLastTerm,
                IdentityNo = IdentityNo,
                MemberId = MemberId,
                MobilePhone = MobilePhone,
                OpenBankCity = OpenBankCity,
                OpenBankName = OpenBankName
            };
        }

        /// <summary>
        /// 创建银行卡验证
        /// </summary>
        /// <returns></returns>
        public IBankCardVerify CreateBankCardVerify()
        {
            return new BankCardVerify()
            {
                CardNo = AccountNo,
                IdentityNo = IdentityNo,
                MobilePhone = MobilePhone,
                RealName = AccountName
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="smsCheckCodeHash"></param>
        /// <param name="smsExpireMinute"></param>
        /// <returns></returns>
        public MerchantMemberBankCardBindApplyToken CreateToken(string smsCheckCodeHash, string channelId, int smsExpireMinute)
        {
            return new MerchantMemberBankCardBindApplyToken()
            {
                AccountName = this.AccountName,
                AccountNo = this.AccountNo,
                AccountType = this.AccountType,
                AppId = this.AppId,
                BankNo = this.BankNo,
                ChannelId = channelId,
                SmsCheckCodeHash = smsCheckCodeHash,
                SmsExpireMinute = smsExpireMinute,
                CreditCardLastNo = this.CreditCardLastNo,
                CreditCardLastTerm = this.CreditCardLastTerm,
                IdentityNo = this.IdentityNo,
                MemberId = this.MemberId,
                MobilePhone = this.MobilePhone,
                OpenBankCity = this.OpenBankCity,
                OpenBankName = this.OpenBankName,
                OpenBankProvince = this.OpenBankProvince,

            };
        }

    }
}
